return;
priv->magnifier = _gtk_magnifier_new (GTK_WIDGET (text_view));
- gtk_widget_set_size_request (priv->magnifier, 100, 60);
_gtk_magnifier_set_magnification (GTK_MAGNIFIER (priv->magnifier), 2.0);
priv->magnifier_popover = gtk_popover_new (GTK_WIDGET (text_view));
gtk_style_context_add_class (gtk_widget_get_style_context (priv->magnifier_popover),
static void
gtk_text_view_show_magnifier (GtkTextView *text_view,
GtkTextIter *iter,
- gint x)
+ gint x,
+ gint y)
{
cairo_rectangle_int_t rect;
GtkTextViewPrivate *priv;
- GtkAllocation allocation;
+ GtkRequisition req;
- _gtk_text_view_ensure_magnifier (text_view);
- gtk_widget_get_allocation (GTK_WIDGET (text_view), &allocation);
+#define N_LINES 1
priv = text_view->priv;
+ _gtk_text_view_ensure_magnifier (text_view);
+
+ /* Set size/content depending on iter rect */
gtk_text_view_get_iter_location (text_view, iter,
(GdkRectangle *) &rect);
+ rect.x = x + priv->xoffset;
gtk_text_view_buffer_to_window_coords (text_view, GTK_TEXT_WINDOW_TEXT,
rect.x, rect.y, &rect.x, &rect.y);
_text_window_to_widget_coords (text_view, &rect.x, &rect.y);
- rect.x = x;
+ req.height = rect.height * N_LINES *
+ _gtk_magnifier_get_magnification (GTK_MAGNIFIER (priv->magnifier));
+ req.width = MAX ((req.height * 4) / 3, 80);
+ gtk_widget_set_size_request (priv->magnifier, req.width, req.height);
_gtk_magnifier_set_coords (GTK_MAGNIFIER (priv->magnifier),
rect.x, rect.y + rect.height / 2);
+
+ rect.y += rect.height / 4;
+ rect.height -= rect.height / 4;
gtk_popover_set_pointing_to (GTK_POPOVER (priv->magnifier_popover),
&rect);
+
gtk_widget_show (priv->magnifier_popover);
+
+#undef N_LINES
}
static void
}
if (_gtk_text_handle_get_is_dragged (priv->text_handle, cursor_pos))
- gtk_text_view_show_magnifier (text_view, &cursor, x);
+ gtk_text_view_show_magnifier (text_view, &cursor, x, y);
else
- gtk_text_view_show_magnifier (text_view, &bound, x);
+ gtk_text_view_show_magnifier (text_view, &bound, x, y);
}
static void
{
_gtk_text_view_ensure_text_handles (text_view);
gtk_text_view_update_handles (text_view, GTK_TEXT_HANDLE_MODE_SELECTION);
- gtk_text_view_show_magnifier (text_view, &cursor, x);
+ gtk_text_view_show_magnifier (text_view, &cursor, x, y);
}
}